<template>
  <!--   待办首页  -->
  <view>
    <view v-if="!isEmpty" class="todo-list">
      <todo-item
        v-if="data && data.aiAlarmTodoCount"
        label="AI视频监控"
        :count="data.aiAlarmTodoCount"
        @click="goAiAlarm"
      />
      <todo-item
        v-if="data && data.ticketAnalysisTodoCount"
        label="作业票气体分析"
        :count="data.ticketAnalysisTodoCount"
        @click="goSpwAnalyse"
      />
      <todo-item
        v-if="data && data.checkPlanTaskTodoCount"
        label="管控排查"
        :count="data.checkPlanTaskTodoCount"
        @click="goControlCheck"
      />
      <todo-item
        v-if="data && data.projectNum"
        label="作业项目审批"
        :count="data.projectNum"
        @click="goProjectApprove"
      />
      <todo-item
        v-if="data && data.dangerPlanTaskTodoCount"
        label="隐患排查"
        :count="data.dangerPlanTaskTodoCount"
        @click="goHiddenDangerCheck"
      />
      <todo-item
        v-if="data && data.dangerManagerTodoCount"
        label="隐患处理"
        :count="data.dangerManagerTodoCount"
        @click="goHiddenDangerDeal"
      />
      <todo-item
        v-if="data && data.dangerPlanTaskDistributeTodoCount"
        label="隐患排查任务派发"
        :count="data.dangerPlanTaskDistributeTodoCount"
        @click="goHiddenDangerDispatch"
      />
      <todo-item
        v-if="data && data.workTicketTodoCount"
        label="作业票处理"
        :count="data.workTicketTodoCount"
        @click="goSpecialWorkTodo"
      />
      <todo-item
        v-if="data && data.alarmCheckTodoCount"
        label="报警核验"
        :count="data.alarmCheckTodoCount"
        @click="goWarnningCheckTodo"
      />
      <todo-item
        v-if="data && data.dangerSuperviseTodoCount"
        label="整改督办"
        :count="data.dangerSuperviseTodoCount"
        @click="goDoBanTodo"
      />
      <todo-item
        v-if="data && data.spotMyTodoCount"
        label="点检事项"
        :count="data.spotMyTodoCount"
        @click="goSpotTodo"
      />
      <todo-item
        v-if="data && data.lubricationMyTodoCount"
        label="润滑事项"
        :count="data.lubricationMyTodoCount"
        @click="goLubricationTodo"
      />
      <todo-item
        v-if="data && data.maintainMyTodoCount"
        label="维护保养事项"
        :count="data.maintainMyTodoCount"
        @click="goMaintenanceTodo"
      />
      <todo-item v-if="data && data.trainCount" label="在线培训" :count="data.trainCount" @click="goOnlineTrain" />
      <todo-item v-if="data && data.examCount" label="在线考试" :count="data.examCount" @click="goOnlineExamination" />
      <todo-item
        v-if="data && data.alarmInfoCount"
        label="人员定位报警"
        :count="data.alarmInfoCount"
        @click="goAlarmInfo"
      />
      <todo-item v-if="data && data.dockWorkCount" label="装卸作业" :count="data.dockWorkCount" @click="goDockWork" />
      <todo-item v-if="data && data.surveyCount" label="调研问卷" :count="data.surveyCount" @click="goSurvey" />
    </view>
    <view v-else>
      <Empty></Empty>
    </view>
  </view>
</template>

<script>
import Empty from '@/components/cu-empty/index.vue'
import NavBar from './nav-bar.vue'
import TodoItem from './todo-item.vue'
import store from '@/store'
import { reqUnreadMessageCount } from '../../../api/message'
export default {
  components: {
    Empty,
    NavBar,
    TodoItem
  },
  props: {
    data: {
      type: Object,
      default: null
    }
  },
  computed: {
    isEmpty() {
      if (!this.data) {
        return true
      }
      return Object.values(this.data).every((pet) => pet === 0 || pet === null)
    }
  },
  methods: {
    goControlCheck() {
      if (store.getters.imeiCode) {
        uni.navigateTo({
          url: '/pages/work/controlCheck/list'
        })
      } else {
        this.$modal.msg('您还未录入IMEI识别码，请先完成录入，否则将无法进行管控排查。')
        setTimeout(function () {
          uni.switchTab({
            url: '/pages/mine/index'
          })
        }, 1500)
      }
    },
    goAiAlarm() {
      uni.navigateTo({
        url: '/pages/alarm/ai-alarm/index'
      })
    },
    goSpwAnalyse() {
      uni.navigateTo({
        url: '/pages/jobSlip/ticket-analyse/index'
      })
    },
    goHiddenDangerCheck() {
      uni.navigateTo({
        url: '/pages/work/hiddenDangerCheck/list'
      })
    },
    goHiddenDangerDeal() {
      uni.navigateTo({
        url: '/pages/work/hiddenDangerDeal/list'
      })
    },
    goHiddenDangerDispatch() {
      uni.navigateTo({
        url: '/pages/work/hiddenDangerDispatch/list'
      })
    },
    goSpecialWorkTodo() {
      uni.navigateTo({
        url: '/pages/jobSlip/todo'
      })
    },
    goShiftingDuty() {
      uni.navigateTo({
        url: '/pages/work/team-or-group/shifting-duty/todo'
      })
    },
    goSafetyMeeting() {
      uni.navigateTo({
        url: '/pages/work/team-or-group/safety-meeting/index?isMyBacklog=1'
      })
    },
    goWarnningCheckTodo() {
      uni.navigateTo({
        url: '/pages/work/warnningCheck/warnningList?from=center'
      })
    },
    goDoBanTodo() {
      uni.navigateTo({
        url: '/pages/work/hiddenDangerDoban/list'
      })
    },
    goSpotTodo() {
      uni.navigateTo({
        url: '/pages/work/intelligentPatrolInspection/spotCheck/index'
      })
    },
    goMaintenanceTodo() {
      uni.navigateTo({
        url: '/pages/work/intelligentPatrolInspection/maintenanceMatter/index'
      })
    },
    goLubricationTodo() {
      uni.navigateTo({
        url: '/pages/work/intelligentPatrolInspection/lubricationMatter/index'
      })
    },
    goOnlineTrain() {
      uni.navigateTo({
        url: '/pages/work/training-tasks/index'
      })
    },
    goOnlineExamination() {
      uni.navigateTo({
        url: '/pages/work/online-examination/index'
      })
    },
    goTrainResearch() {
      uni.navigateTo({
        url: '/pages/work/training-research/index'
      })
    },
    goAlarmInfo() {
      uni.navigateTo({
        url: '/pages/work/alarm-info/list'
      })
    },
    goSurvey() {
      uni.navigateTo({
        url: '/pages/work/training-research/index'
      })
    },
    goDockWork() {
      uni.navigateTo({
        url: '/pages/work/add-load-operation/list'
      })
    },
    goPowerCut() {
      uni.navigateTo({
        url: '/pages/jobSlip/power-cut/todo'
      })
    },
    goProjectApprove() {
      uni.navigateTo({
        url: '/pages/jobSlip/work-project/list'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.todo-list {
  display: flex;
  justify-content: start;
  padding: 30rpx 15rpx;
  flex-wrap: wrap;
}
</style>
